package com.jinzhi.jzweb.controller.backstage;


import com.jinzhi.common.utils.Result;
import com.jinzhi.jzweb.domain.vo.home.OrderRechargeVo;
import com.jinzhi.jzweb.service.JazUserOrderService;
import com.jinzhi.jzweb.service.WxValidationService;
import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 * @author JingChangTian
 * @since 2023-06-16
 */
@Controller
@RequestMapping("/home")
@Api(value = "首页管理", tags = "首页管理")
public class HomePageController {

    /**
     * 业务层，充值
     */
    private final JazUserOrderService jazUserOrderService;

    private final WxValidationService wxValidationService;

    public HomePageController(JazUserOrderService jazUserOrderService, WxValidationService wxValidationService) {
        this.jazUserOrderService = jazUserOrderService;
        this.wxValidationService = wxValidationService;
    }


    @ApiOperation(value = "收入订单统计", notes = "收入订单统计")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/getOrderRecharge")
    public Result<OrderRechargeVo> getOrderRecharge(Integer type,String startTime,String endTime){
       return Result.ok(jazUserOrderService.getOrderRecharge(type,startTime,endTime));
    }


    @ApiOperation(value = "效验文本敏感信息", notes = "效验文本敏感信息")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @PostMapping(value = "/validation")
    public Result<Object> validation(@RequestParam String content){
        return Result.ok(wxValidationService.msgValidation(content));
    }

    @ApiOperation(value = "获取accessToken", notes = "获取accessToken")
    @ApiImplicitParams({
    })
    @ApiResponses({@ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = 500, message = "服务器内部异常")})
    @ResponseBody
    @GetMapping (value = "/accessToken")
    public Result<Object> accessToken(){
        return Result.ok(wxValidationService.accessToken());
    }


}
